package com.changanw.account.controller;

import com.changanw.account.service.AccountService;
import com.changanw.common.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class AccountController {
    @Autowired
    AccountService accountService;

    /**
     * 扣款请求
     * @param account
     * @param money
     * @return
     */
    @PostMapping("/deductAccount")
    public RespBean deduct(String account,Double money){
        boolean b = accountService.deductAccount(account, money);
        if (b){
            return RespBean.ok("扣款成功");
        }
        return RespBean.error("扣款失败");
    }
}
